#include <iostream>
using namespace std;

// 重载 << 作为类的 friend 有元函数（重载函数）  
class Computer
{
public:
    //有参构造函数
    Computer(int real, int image)
    :_real(real)
    ,_image(image)
    {  }

    //无参构造函数
    Computer()
    {}
    // 作为friend
    friend // cout 输出重载
        ostream & operator<<(ostream & os,const Computer & rhs);
    friend// cin 输入重载
        istream & operator>>(istream & is, Computer & rhs);
private:
    int _real;
    int _image;
};
istream & operator>>(istream & is, Computer & rhs){
    cout << "输入实部" << endl;
    is >> rhs._real;
    cout << "输入虚部" << endl;
    is >> rhs._image;
    return is;
}
// 因为我上面写了cout <<
// 所以要在这个istream之后再来重载函数
ostream & operator<<(ostream & os,const Computer & rhs){
    os << "_real=" << rhs._real<< " " << "_image=" << rhs._image << endl;
    return os;
}
void test(){
    Computer p;
    cin >> p;
    cout << p;
}

int main(int atgc, char * argv[])
{
    test();
    return 0;
}

